In [1]:
from pyndamics import *
In [2]:
sim=Simulation()
sim.add("x'=a*x+b*y",1,plot=True)
sim.add("y'=c*x+d*y",0,plot=True)
sim.params(a=0,b=1,c=-1,d=0)
sim.run(0,20)
In [3]:
phase_plot(sim,'x','y')
axis('equal')
Out[3]:
In [4]:
sim=Simulation()
sim.add("v'=I+v*(1-v)*(v-a) -w",0,plot=True)
sim.add("w'=eps*(v-gamma*w)",0,plot=True)
sim.params(I=0.4,a=0.1,eps=0.1,gamma=0.25)
sim.run(100)
In [5]:
vector_field(sim,v=linspace(-.25,1.25,30),w=linspace(-.5,1,30))
phase_plot(sim,'v','w')
In [6]:
sim=Simulation()
sim.add("x'=v",.1)
sim.add("v'=a*x*(1-x**2)-f*v+c*cos(omega*t)",.1)
sim.params(a=1,f=.2,c=.3,omega=1)
sim.run(200,num_iterations=20000)
phase_plot(sim,'x','v')
In [7]:
def f(u):
return 1.0/(1+exp(u))
sim=Simulation()
sim.add("u'=-u+f(a*u-b*v+p)",0,plot=True)
sim.add("v'=-v+f(c*u-d*v+q)",0,plot=True)
sim.functions(f)
sim.params(a=16,b=12,c=16,d=5,p=-1,q=-4)
sim.run(10)
In [8]:
sim=Simulation()
sim.add("theta'=v",10,plot=True)
sim.add("v'=-(g/L)*sin(theta)",plot=True)
sim.add("E=m*((L*v)**2/2+g*L*(1-cos(theta)))",plot=True)
sim.params(g=9.8,L=2,m=1)
sim.run(10)
In [9]:
sim=Simulation()
sim.add("R=x**2+y**2")
sim.add("x'=x*(a-R)-y*(1+q*R)",10,plot=True)
sim.add("y'=y*(a-R)+x*(1+q*R)",0,plot=True)
sim.params(a=1,q=1 )
sim.run(10)
In [10]:
sim=Simulation()
sim.add("x'=x+y+x**2-y**2+0.1",0.1,plot=True)
sim.add("y'=y-2*x*y+x**2/2+y**2",0,plot=True)
sim.run(1.2)
In [11]:
vector_field(sim,x=linspace(-6,6,30),y=linspace(-6,6,30))
In [ ]:
In [ ]: